Skip to content

Instantly share code, notes, and snippets.

@guaracyalima
guaracyalima / lab.md
Created March 4, 2025 11:17
Laboratórios práticos

Laboratórios práticos

  1. Criação e manipulação de arquivos em ambiente Unix/Linux
    Em uma infraestrutura de servidores de uma grande organização, um analista de suporte precisa criar um arquivo de log para registrar eventos críticos. Para isso, ele deve:
    • Criar um arquivo chamado sistema.log no diretório /var/logs/custom/.
    • Inserir a seguinte entrada de log no arquivo:

[2025-03-04 14:35:00] ALERTA: O sistema identificou uma tentativa de acesso não autorizado.

<ehcache xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
xsi:noNamespaceSchemaLocation="<http://ehcache.org/ehcache.xsd>"
monitoring="autodetect"
dynamicConfig="true">
<diskStore path="java.io.tmpdir/ehcache" />
<cache name="productCache"
maxEntriesLocalHeap="1000"
maxEntriesLocalDisk="5000"
package br.com.zeroth.zth_product_srv.config;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import java.time.Duration;
spring:
data:
redis:
url: redis://${HOST:localhost}:6379
password: 123456
cache:
type: redis
version: '3'
services:
redis:
image: redis:6.2-alpine
container_name: redis
ports:
- "6379:6379"
environment:
- REDIS_PASSWORD=123456
volumes:
// Domain
@Data
@Builder
public class Order {
private Product product;
private ShippingHistory shippingHistory;
private Payment payment;
}
package br.com.zeroth.zth_product_srv.services.impl;
import br.com.zeroth.zth_product_srv.domain.Order;
import br.com.zeroth.zth_product_srv.domain.Payment;
import br.com.zeroth.zth_product_srv.domain.Product;
import br.com.zeroth.zth_product_srv.domain.ShippingHistory;
import br.com.zeroth.zth_product_srv.services.OrderService;
import org.springframework.stereotype.Service;
@Service
package br.com.zeroth.zth_product_srv.services;
import br.com.zeroth.zth_product_srv.domain.Order;
public interface OrderService {
Order getOrderWithDetails(Long orderId);
}
package br.com.zeroth.zth_product_srv.controller;
import br.com.zeroth.zth_product_srv.domain.Order;
import br.com.zeroth.zth_product_srv.services.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
package br.com.zeroth.zth_product_srv.config;
import jakarta.servlet.Filter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.filter.ShallowEtagHeaderFilter;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;